<template>
  <div class="mod-config">
    <basic-container>
      <navigation :sign="{a:false,b:false,c:true,d:false,e:false}"></navigation>
      <div class="boxsty zhiBiao">
        <div class="flex justifyContentSpaceBetween">
          <div class="tabletext">人员奖金维护</div>
          <div class="tablelink">
            <!-- <el-link icon="el-icon-plus" v-if="permissions.jiangjin_jiangjinryxxb_add" type="primary"
                     @click="addOrUpdateHandle()" :underline="false">新增人员信息
            </el-link> -->
            <!--            <el-link icon="el-icon-plus" v-if="permissions.jiangjin_jiangjinryxxb_add" type="primary" @click="importFileHandle()" :underline="false">导入人员信息</el-link>-->

            <span
              style="float: right; cursor: pointer"
              @click="searchchangeadvanced"
            >{{ searchadvanced ? "查询条件收起" : "查询条件展开" }}
                  <i :class="searchadvanced ? 'el-icon-arrow-up' : 'el-icon-arrow-down'"/>
              </span>
          </div>
        </div>
        <div v-show="searchadvanced">
          <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()" class="form-inline">
            <el-form-item label="姓名">
              <el-input v-model="dataForm.ryXm" placeholder="姓名" clearable></el-input>
            </el-form-item>
            <el-form-item label="员工编号">
              <el-input v-model="dataForm.ryCode" placeholder="员工编号"></el-input>
            </el-form-item>
            <el-form-item label="所属部门">
              <el-cascader v-model="departmentSelect" :options="departmentOptions"
                           :props="{ multiple: true, checkStrictly: true, expandTrigger: 'hover', value:'id', label:'name' }"
                           clearable></el-cascader>
            </el-form-item>
            <el-form-item label="考核等级">
              <el-select :clearable="true" v-model="dataForm.config03" placeholder="请选择" class="xiaLa wbf90">
                <el-option v-for="(item,index) in userKhdjOptions " :key="index" :label="item.label"
                           :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="岗位层级">
              <el-select :clearable="true" v-model="dataForm.ryZwjbbh" placeholder="请选择" class="xiaLa wbf90">
                <el-option v-for="(item,index) in userZjOptions " :key="index" :label="item.label" :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="岗位">
              <el-input v-model="dataForm.ryZhiwei" placeholder="岗位"></el-input>
            </el-form-item>
            <el-form-item label="负责部门：">
              <el-select v-model="dataForm.deptId" placeholder="请选择负责部门" class="xiaLa" style="width: 300px"
                         @change="switchDepartment">
                <el-option v-for="(item,index) in fzbmData" :key="index" :label="item.deptName"
                           :value="item.deptId"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item>
              <el-button type="primary" class="marginLeft" plain @click="getDataList(1)">检索</el-button>
            </el-form-item>
          </el-form>
        </div>

        <div style="height: 50px;">
          <!-- <div style="height: 50px;"> -->
          <el-tooltip
            class="item"
            effect="dark"
            content="系数配置"
            placement="top"
          >
            <el-button
              icon="el-icon-tickets"
              type="success"
              v-if="permissions.jiangjin_jiangjinryxxb_edit"
              @click="paramConfig"
              circle
            ></el-button>
          </el-tooltip>
          <!-- <el-tooltip
            class="item"
            effect="dark"
            content="分级统一系数配置"
            placement="top"
          >
            <el-button
              icon="el-icon-document-copy"
              type="success"
              v-if="permissions.jiangjin_jiangjinryxxb_edit"
              @click="paramConfigBatch"
              circle
            ></el-button>
          </el-tooltip> -->
          <el-tooltip
            class="item"
            effect="dark"
            content="单项奖惩查看"
            placement="top"
          >
            <el-button
              icon="el-icon-search"
              type="primary"
              @click="ShowJC"
              circle
            ></el-button>
          </el-tooltip>
          <el-tooltip
            class="item"
            effect="dark"
            content="新增人员信息"
            placement="top"
          >
            <el-button
              icon="el-icon-plus"
              type="warning"
              v-if="permissions.jiangjin_jiangjinryxxb_add"
              @click="addOrUpdateHandle()"
              circle
            ></el-button>
          </el-tooltip>
          <el-tooltip
            class="item"
            effect="dark"
            content="修改人员信息"
            placement="top"
          >
            <el-button
              icon="el-icon-edit"
              type="warning"
              v-if="permissions.jiangjin_jiangjinryxxb_edit"
              @click="UpdateOper"
              circle
            ></el-button>
          </el-tooltip>
          <el-tooltip
            class="item"
            effect="dark"
            content="删除人员及系数信息"
            placement="top"
          >
            <el-button
              icon="el-icon-delete"
              type="danger"
              v-if="permissions.jiangjin_jiangjinryxxb_del"
              @click="delMulti"
              circle
            ></el-button>
          </el-tooltip>

          <div class="pull-right">
            <el-dropdown style="margin-right:10px;">
              <el-button type="primary" plain>
                模板下载<i class="el-icon-arrow-down el-icon--right"></i>
              </el-button>
              <el-dropdown-menu slot="dropdown">
                 <!-- :data="uploadDataForDetail" -->
                <!-- <el-dropdown-item>
                  <el-upload
                    action='/admin/sys-file/upload'
                    accept=".xlsx, .xls"
                    :headers="headers"
                    class="upload-demo inline-block"
                    :before-upload="beforeAvatarUpload"
                    :on-success="handleUploadSuccessTwo"
                    :show-file-list="false"
                    style="padding-left:10px;padding-right:10px">

                    领导年度考核导入
                  </el-upload>
                </el-dropdown-item>
                <el-dropdown-item  @click.native="downLoad">
                 <span style="margin-left:10px;">领导年度考核模板</span>
                </el-dropdown-item> -->
                <el-dropdown-item
                 v-if="permissions.jiangjin_jiangjinryxxb_add"
                @click.native="importFileHandle()"
                >
                <span style="margin-left:10px;">基本信息导入</span>
                </el-dropdown-item>
                <el-dropdown-item
                @click.native="excelExportHandleDown('员工个人信息')"
                >
                  <span style="margin-left:10px;">基本信息导出</span>
                </el-dropdown-item>
                <el-dropdown-item
                   @click.native="temopDow"
                >
                  <span style="margin-left:10px;">基本信息模板下载</span>
                </el-dropdown-item>
                <el-dropdown-item
                   @click.native="jiangjinExport"
                >
                  <span style="margin-left:10px;">配置导出</span>
                </el-dropdown-item>
                <el-dropdown-item>
                  <el-upload
                    action='/jiangjin/jiangjinryxxb/importExcelForDetail'
                    accept=".xlsx, .xls"
                    :headers="headers"
                    class="upload-demo inline-block"
                    :before-upload="beforeAvatarUpload"
                    :on-success="handleUploadSuccess"
                    :on-error="handleUploadError"
                    :data="uploadDataForDetail"
                    :show-file-list="false"
                    style="padding-left:10px;padding-right:10px">
                    配置导入
                  </el-upload>
                </el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
            <el-button @click="showJobLevelConfig" type="primary" plain>职级奖金配置</el-button>
            <el-button type="primary" plain @click="btnAllocationXxPz" v-if="deptId != ''">系数详细配置</el-button>
            <el-button type="primary" plain @click="scoreBtn">获取评分汇总数据</el-button>
            <!--            <el-button type="warning" plain>获取业绩合同</el-button>-->
            <!--            <el-button type="warning" plain>获取日常考核</el-button>-->
          </div>
        </div>
        <!-- <span>&nbsp;<el-button v-if="permissions.jiangjin_jiangjinryxxb_del" @click="delMulti" type="primary" plain size="small">批量删除</el-button></span>
        <div>&nbsp;</div> -->

        <el-table :data="dataList" @selection-change="handleSelectionChange" ref="table" border v-loading="dataListLoading"
                  class="avue-crud">
          <el-table-column type="selection" width="55" header-align="center" align="center"></el-table-column>
          <el-table-column prop="" header-align="center" align="center" label="序号" width="80"
                           :formatter="nShowIndex"></el-table-column>
          <el-table-column prop="ryXm" header-align="center" align="center" label="姓名"></el-table-column>
          <el-table-column prop="ryCode" header-align="center" align="center" label="人员编号"></el-table-column>
          <el-table-column prop="rySjdw" header-align="center" align="center" show-overflow-tooltip label="所属部门"
                           width="400"></el-table-column>
          <el-table-column prop="ryZhiwei" header-align="center" align="center" show-overflow-tooltip
                           label="岗位"></el-table-column>
          <el-table-column prop="ryZwjbbh" header-align="center" align="center" label="岗位层级">
            <template slot-scope="scope">
              {{ zjzh(scope.row.ryZwjbbh) }}
            </template>
          </el-table-column>
          <!-- <el-table-column prop="config03" header-align="center" align="center" label="考核等级"></el-table-column> -->
          <!-- <el-table-column label="操作" width="400px">
            <template slot-scope="scope">
              <el-button v-if="permissions.jiangjin_jiangjinryxxb_edit" type="primary" plain size="small"
                         @click="btnAllocation(scope.row.ryCode)">系数配置
              </el-button>
             <el-button v-if="permissions.jiangjin_jiangjinryxxb_edit" type="primary" plain size="small"
                        @click="btnReward(scope.row.ryCode)">奖金查看
             </el-button>
              <el-button v-if="permissions.jiangjin_jiangjinryxxb_edit" type="primary" plain size="small"
                         @click="btnJc(scope.row.ryCode)">单项奖惩查看
              </el-button>
              <el-button v-if="permissions.jiangjin_jiangjinryxxb_edit" type="primary" plain size="small"
                         @click="addOrUpdateHandle(scope.row.ryCode)">修改
              </el-button>
              <el-button v-if="permissions.jiangjin_jiangjinryxxb_del" type="danger" plain size="small"
                         @click="deleteHandle(scope.row.ryCode)">删除
              </el-button>
            </template>
          </el-table-column> -->
        </el-table>

        <div class="avue-crud__pagination">
          <el-pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" :current-page="pageIndex"
                         :page-sizes="[10, 20, 50, 100]" :page-size="pageSize" :total="totalPage" background
                         layout="total, sizes, prev, pager, next, jumper">
          </el-pagination>
        </div>
      </div>
      <!-- 弹窗, 新增 / 修改 -->
      <table-form v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></table-form>
      <!-- 导入 -->
      <imp-ex-file v-if="importFileVisible" ref="impExFile" @refreshDataList="getDataList"></imp-ex-file>
      <!-- 配置 -->
      <tallocation v-if="allocationVisible" ref="tallocation" @refresh="getDataList"></tallocation>
      <!-- 单项奖惩查看 -->
      <bonusPenalty v-if="bonusPenaltyVisible" ref="bonusPenalty"></bonusPenalty>
      <!-- 奖金查看  -->
      <reward v-if="rewardVisible" ref="reward"></reward>
      <!-- 配置导入 -->
      <impAllocation v-if="impAllocationVisible" ref="impAllocation"></impAllocation>
      <!-- 职级奖金配置 -->
      <job-level-config v-if="jobLevelConfigVisible" ref="refJobLevelConfig"/>
      <!-- 人员新增和修改 -->
      <add-update-oper v-if="addUpdateOperVisible" ref="refAddUpdateOper" @addUpdateOk="getDataList"/>
      <!-- 系数详细配置 -->
      <TallocationXxPz v-if="allocationVisibleXxPz" ref="tallocationXxPz" ></TallocationXxPz>
      <!--配置导出前选择奖金项-->
      <el-dialog
        title="选择奖金项"
        :visible.sync="peiDialogVisible"
        width="30%"
        center>
        <div>
          <el-form :model="peiForm" label-width="180px">
            <el-form-item label="奖金项">
              <el-select
                v-model="peiForm.jjxIds"
                placeholder="选择奖金项"
                clearable
                multiple
                style="width: 80%;"
              >
                <el-option
                  v-for="(item, index) in jjxOptions"
                  :key="index"
                  :label="item.jjxMc"
                  :value="item.id"
                >
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="配置系数">
              <el-select
                v-model="peiForm.jjXs"
                placeholder="选择配置系数"
                clearable
                multiple
                style="width: 80%;"
              >
                <el-option value="config03" label="个人考核分级"></el-option>
                <el-option value="config01" label="工时(工作量)奖励"></el-option>
                <el-option value="config02" label="员工考核基础分"></el-option>
                <el-option value="config04" label="员工月绩效考核分"></el-option>
                <el-option value="config06" label="综合业绩分值"></el-option>
                <el-option value="config08" label="个人绩效分数"></el-option>
                <el-option value="config05" label="绩效年薪基数"></el-option>
                <el-option value="config07" label="绩效奖金基数"></el-option>
                <el-option value="config09" label="绩效分值指数"></el-option>
              </el-select>
            </el-form-item>
          </el-form>
        </div>
        <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="allocationExport">确 定</el-button>
        <el-button @click="quxiao">取 消</el-button>
      </span>
      </el-dialog>
      <!--获取评分汇总数据-->
      <el-dialog
        title="获取评分汇总数据"
        :visible.sync="scoreDialogVisible"
        width="60%"
        :close-on-click-modal="false"
        center>
        <div>
          <el-form ref="form" :model="scoreForm" label-width="80px">
            <el-form-item label="评分汇总">
              <el-select v-model="scoreForm.id" placeholder="请选择评分汇总" @change="scoreChange">
                <el-option v-for="item in scoreList" :label="item.tjmc" :value="item.id"></el-option>
              </el-select>
            </el-form-item>
          </el-form>
          <el-table
          v-if="scoreTableData.length>0"
          :data="scoreTableData"
          align="center"
          style="width: 100%">
          <el-table-column
            prop="ryCode"
            label="人员编号"
            align="center"
            width="180">
          </el-table-column>
          <el-table-column
            prop="userName"
            label="人员名称"
            align="center"
            width="180">
          </el-table-column>
          <el-table-column
            prop="config06"
            align="center"
            label="综合业绩分值">
          </el-table-column>
          <el-table-column
            prop="config03"
            align="center"
            min-width="110"
            label="个人考核分级">
          </el-table-column>
          
        </el-table>
        </div>
        <span slot="footer" class="dialog-footer">
          <el-button type="primary" @click="onscore">确 定</el-button>
          <el-button @click="scoreDialogVisible = false">取 消</el-button>
        </span>
      </el-dialog>
    </basic-container>
  </div>
</template>

<script>
import {remote as remoteDict} from '@/api/admin/dict';
import {fetchList, delObj, delRyListObj,gethzzqList,getRyxxDataListBypfhz,updateOrSavedatalist} from '@/api/jiangjin/jiangjinryxxb';
import {getJjDeptJjx} from "@/api/jiangjin/jiangjinjjxxxb";
import {fetchTree} from '@/api/admin/dept';

import TableForm from './jiangjinryxxb-form';
import impExFile from "./importExFile";
import Tallocation from "./codeRyxx";
import impAllocation from './importAllocation'
import JobLevelConfig from './JobLevelConfig'
import AddUpdateOper from './AddUpdateOper'

import bonusPenalty from '@/components/currency/bonus-penalty';
import reward from '@/components/currency/reward';
import request from '@/router/axios'
import {getJiangJinBm} from '@/api/admin/dept'
import {mapGetters} from 'vuex'
import store from "@/store";
import TallocationXxPz from "../jiangjinryxxb/xiangxiPzRyxx"
import { getStore, setStore } from "@/util/store";

export default {
  data() {
    return {
      departmentOptions: [],
      departmentSelect: [],
      userKhdjOptions: [{value: 'A', label: 'A'}, {value: 'B', label: 'B'}, {value: 'C', label: 'C'}, {
        value: 'D',
        label: 'D'
      }], // 考核等级
      userZjOptions: [], // 职级
      deptId: "",
      deptName: "",
      dataForm: { // 检索条件data
        ryXm: '',
        ryCode: '',
        rySjdw: '',
        config03: '', // 考核等级
        ryZwjbbh: '',
        ryZhiwei: ''
      },
      dataList: [],
      pageIndex: 1,
      pageSize: 10,
      totalPage: 0,
      dataListLoading: false,
      addOrUpdateVisible: false,
      importFileVisible: false,
      multipleSelection: [],
      allocationVisible: false,
      bonusPenaltyVisible: false,
      rewardVisible: false,
      impAllocationVisible: false,
      jobLevelConfigVisible: false,
      addUpdateOperVisible: false,
      allocationVisibleXxPz: false,
      // 查询条件隐藏/显示相关
      searchheight: "0",
      searchadvanced: true,
      peiDialogVisible: false,
      jjxOptions: [],
      peiForm: {
        jjxIds: [],
        jjXs:[]
      },
      fzbmData: [],
      //---------------导入导出-------------
      headers: {
        'TENANT-ID': getStore({ name: "tenantId" })
              ? getStore({ name: "tenantId" })
              : "1",
        Authorization: "Bearer " + store.getters.access_token,
      },
      uploadDataForDetail: {deptId: undefined},
      bLoading:false,
      scoreDialogVisible:false,
      scoreForm:{
        id:""
      },
      scoreList:[],
      scoreTableData:[]
    }
  },
  components: {
    TableForm,
    impExFile,
    Tallocation,
    bonusPenalty,
    reward,
    impAllocation,
    JobLevelConfig,
    AddUpdateOper,
    TallocationXxPz
  },
  created() {
    // 初始化所属部门列表
    fetchTree().then(response => {
      this.departmentOptions = this.dealTreeData(response.data.data)
    })


    this.multipleSelection = [];
  },
  mounted() {
    this.getJiangJinJg();
  },
  computed: {
    ...mapGetters(['permissions'])
  },
  methods: {
    scoreBtn(){
        this.scoreDialogVisible=true
        this.$set(this.scoreForm,'id','')
        this.scoreTableData=[]
        gethzzqList().then(res=>{
          this.scoreList=res.data.data
        })
    },
    scoreChange(){
      if(this.scoreForm.id){
        getRyxxDataListBypfhz(this.scoreForm.id).then(res=>{
            this.scoreTableData=res.data.data
        })
      }
    },
    onscore(){
      updateOrSavedatalist(this.scoreTableData).then(res=>{
        if(res.data.code==0){
          this.$message.closeAll()
          this.$message.success('获取成功!')
          this.getJiangJinJg();
          this.scoreDialogVisible=false
        }
      })
    },
    // 处理部门tree数据，将最后的children:[]改成undefined,否则级联下拉框会多出一层
    dealTreeData(data) {
      // 循环遍历json数据
      for (var i = 0; i < data.length; i++) {
        if (data[i].children.length < 1) {
          // children若为空数组，则将children设为undefined
          data[i].children = undefined;
        } else {
          // children若不为空数组，则继续 递归调用 本方法
          this.dealTreeData(data[i].children);
        }
      }
      return data;
    },
    //获取奖金项列表
    getJjDeptJjx() {
      getJjDeptJjx(this.deptId).then((res) => {
        this.jjxOptions = res.data.data;
      });
    },
    //负责部门改变
    switchDepartment(deptId) {
      for (var a in this.fzbmData) {
        if (this.fzbmData[a].deptId == deptId) {
          this.deptId = this.fzbmData[a].deptId;
          this.deptName = this.fzbmData[a].deptName;
          this.getJjDeptJjx()
          this.refresh();

          break;
        }
      }
    },
    quxiao() {
      this.peiDialogVisible = false;
      this.peiForm = {
        jjxIds: [],
        jjXs: []
      }
    },
    searchchangeadvanced() {
      this.searchadvanced = !this.searchadvanced;
      if (this.searchadvanced) {
        this.searchheight = "50";
      }
    },

    allocationImport() {
      this.impAllocationVisible = true;
      this.$nextTick(() => {
        this.$refs.impAllocation.init()
      })
    },

    // 职级奖金配置
    showJobLevelConfig() {
      this.jobLevelConfigVisible = true;
      this.$nextTick(() => {
        this.$refs.refJobLevelConfig.init()
      });
    },
    jiangjinExport() {
      this.peiDialogVisible = true
    },
    allocationExport() {

      const filename = "员工基本配置";
      let jjxIds
      let jjXs
      if (this.peiForm.jjxIds.length > 0) {
        jjxIds = this.peiForm.jjxIds.toString()
      }
      if (this.peiForm.jjXs.length > 0) {
        jjXs = this.peiForm.jjXs.toString()
      }
      this.$message.closeAll()
      if (!jjxIds) {
        this.$message.error("请选择要导出的奖金项");
        return
      }
      var data=this.$refs.table.selection;
      var userIds=[]
     if(data.length>0){
       data.forEach(item => {
         userIds.push(item.userId)
       });
     }else{
       userIds=[]
     }
     userIds=userIds.toString()
     var params={
       jjxIds:jjxIds,
       jjXs:jjXs,
       userIds:userIds,
       form:this.dataForm
     }
      return request({
        url: '/jiangjin/jiangjinryxxb/exportPzNew/',
        method: 'post',
        data:params,
        responseType: 'arraybuffer'
      }).then((response) => { // 处理返回的文件流
        const blob = new Blob([response.data], {
          type: 'application/vnd.ms-excel'
        })
        const link = document.createElement('a')
        link.href = URL.createObjectURL(blob)
        link.download = filename
        document.body.appendChild(link)
        link.click()
        window.setTimeout(function () {
          URL.revokeObjectURL(blob)
          document.body.removeChild(link)
        }, 0)
        this.quxiao()
      })
    },
    downLoad(){
      const filename = "考核分级";
      return request({
        url: '/jiangjin/jiangjinryxxb/downloadMBByRyxxbList/',
        method: 'post',
        //data:params,
        responseType: 'arraybuffer'
      }).then((response) => { // 处理返回的文件流
        const blob = new Blob([response.data], {
          type: 'application/vnd.ms-excel'
        })
        const link = document.createElement('a')
        link.href = URL.createObjectURL(blob)
        link.download = filename
        document.body.appendChild(link)
        link.click()
        window.setTimeout(function () {
          URL.revokeObjectURL(blob)
          document.body.removeChild(link)
        }, 0)

      })
    },
    temopDow() {
      window.location.href = '../../static/员工个人信息模板.xls'
    },
    //获取奖金管理人机构
    getJiangJinJg() {
      getJiangJinBm().then(res => {
        if (res.data.data != null && res.data.data.length > 0) {
          this.deptId = "";
          this.deptName = "";
          this.deptId = res.data.data[0].deptId;
          this.deptName = res.data.data[0].name;
          this.$set(this.dataForm, 'deptId', res.data.data[0].deptId)
          this.fzbmData = res.data.data;
          this.getDataList();
        } else {
          // this.$notify.closeAll();
          // this.$notify.error("没有相关负责部门")
          // this.deptName = "无相关负责部门";
          this.getDataList();
        }
        this.getJjDeptJjx()
      })
      // 获取人员职级代码
      remoteDict("user_zj").then(response => {
        this.userZjOptions = response.data.data
      })

    },
    //职务级别转换
    zjzh(value) {
      for (var a in this.userZjOptions) {
        if (this.userZjOptions[a].value == value) {
          return this.userZjOptions[a].label;
        }
      }
    },
    nShowIndex(row, column, cellValue, index) {
      return index + 1 + this.pageSize * (this.pageIndex - 1);
    },
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    // 获取数据列表
    getDataList(page) {
      if (page) {
        this.pageIndex = page
      }

      // 处理部门级联选择结果：[]->xx,xx
      this.dataForm.rySjdw = ''
      if (this.departmentSelect.length > 0) {
        for (let i = 0; i < this.departmentSelect.length; i++) {
          const dep = this.departmentSelect[i]
          this.dataForm.rySjdw += dep[dep.length - 1] + ','
        }
        this.dataForm.rySjdw = this.dataForm.rySjdw.substring(0, this.dataForm.rySjdw.length - 1)
      }

      this.dataListLoading = true
      fetchList(Object.assign({
        current: this.pageIndex,
        size: this.pageSize
      }, this.dataForm)).then(response => {
        this.dataList = response.data.data.records
        this.totalPage = response.data.data.total
      })
      this.dataListLoading = false
    },
    // 每页数
    sizeChangeHandle(val) {
      this.pageSize = val
      this.pageIndex = 1
      this.getDataList()
    },
    // 当前页
    currentChangeHandle(val) {
      this.pageIndex = val
      this.getDataList()
    },
    // 新增 / 修改--条件判断
    UpdateOper() {
      if (this.multipleSelection.length !== 1) {
        this.$notify.closeAll()
        this.$notify.error("请选择一个人员")
        return
      }
      this.addOrUpdateHandle(this.multipleSelection[0].userName)
    },
    // 新增 / 修改人员
    addOrUpdateHandle(userName) {
      // this.addOrUpdateVisible = true
      // this.$nextTick(() => {
      //   this.$refs.addOrUpdate.init(id)
      // })

      this.addUpdateOperVisible = true;
      this.$nextTick(() => {
        if (userName) {
          this.$refs.refAddUpdateOper.showOperUpdate(userName)
        } else {
          this.$refs.refAddUpdateOper.showOperAdd()
        }
      });
    },
    //配置系数-条件判断
    paramConfig() {
      if (this.multipleSelection.length !== 1) {
        this.$notify.closeAll()
        this.$notify.error("请选择一个人员")
        return
      }
      this.handleParamConfig(this.multipleSelection[0].ryCode)
    },
    //配置系数-单个人
    handleParamConfig(code) {
      if (this.deptId === "") {
        //this.$notify.closeAll();
        //this.$notify.error("没有相关负责部门,无法配置系数");
        return;
      }
      this.allocationVisible = true
      this.$nextTick(() => {
        this.$refs.tallocation.init(code, this.deptId)
      })
    },
    //分级统一系数配置
    paramConfigBatch() {
      if (this.multipleSelection.length === 0) {
        this.$notify.closeAll()
        this.$notify.error("请选择人员")
        return
      }
      // 判断选中的人员考核等级必须相同
      let level = this.multipleSelection[0].config03 // 考核等级
      // for (let i=1; i<this.multipleSelection.length; i++) {
      //   if (level !== this.multipleSelection[i].config03) {
      //     this.$notify.closeAll()
      //     this.$notify.error("考核等级必须相同")
      //     return
      //   }
      // }
      let userCodes = this.multipleSelection.map((item) => {
        return item.ryCode
      })
      this.handleParamConfigBatch(userCodes, level)

    },
    //配置系数-分级统一系数配置
    handleParamConfigBatch(codes, level) {
      if (this.deptId === "") {
        //this.$notify.closeAll();
        //this.$notify.error("没有相关负责部门,无法配置系数");
        return;
      }
      this.allocationVisible = true
      this.$nextTick(() => {
        this.$refs.tallocation.initBatch(codes, level, this.deptId)
      })
    },
    // 单项奖惩查看-条件判断
    ShowJC() {
      if (this.multipleSelection.length !== 1) {
        this.$notify.closeAll()
        this.$notify.error("请选择一个人员")
        return
      }
      this.handleShowJC(this.multipleSelection[0].ryCode)
    },
    //单项奖惩查看
    handleShowJC(code) {
      this.bonusPenaltyVisible = true
      this.$nextTick(() => {
        this.$refs.bonusPenalty.init(code)
      })
    },
    //奖金查看
    btnReward(code) {
      this.rewardVisible = true;
      this.$nextTick(() => {
        this.$refs.reward.init(code)
      })
    },
    // 单个删除
    deleteHandle(id) {
      this.$confirm('是否确认删除', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(function () {
        return delObj(id)
      }).then(data => {
        this.$notify.closeAll();
        this.$notify.success('删除成功');
        this.getDataList()
      })
    },
    //批量删除
    delMulti() {
      ////console.log(this.multipleSelection);
      // return;
      const _that = this;
      if (this.multipleSelection.length === 0) {
        this.$notify.closeAll();
        this.$notify.error("请选择要删除人员");
        return;
      }
      this.$confirm('是否删除选中人员', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(function () {
        // return delObj(id)
        return delRyListObj(_that.multipleSelection)
      }).then(data => {
        this.$notify.closeAll();
        this.$notify.success('删除成功');
        this.getDataList()
      }).catch(err => {
        // this.$notify.closeAll();
        // this.$notify.success('批量删除失败');
      })
    },
    //导入文件
    importFileHandle() {
      this.importFileVisible = true;
      this.$nextTick(() => {
        this.$refs.impExFile.init()
      })
    },
    /**
     * excel 导出下载
     */
    excelExportHandleDown(filename) {
      return request({
        url: '/jiangjin/jiangjinryxxb/export',
        method: 'post',
        responseType: 'arraybuffer',
        data:this.dataForm
      }).then((response) => { // 处理返回的文件流
        const blob = new Blob([response.data], {
          type: 'application/vnd.ms-excel'
        })
        const link = document.createElement('a')
        link.href = URL.createObjectURL(blob)
        link.download = filename
        document.body.appendChild(link)
        link.click()
        window.setTimeout(function () {
          URL.revokeObjectURL(blob)
          document.body.removeChild(link)
        }, 0)
      })
    },
//--------------------导入------------
    /**
     * 文件上传前
     */
    beforeAvatarUpload(file) {
      this.uploadDataForDetail.deptId = this.deptId
      this.loading = this.$loading({
        lock: true,
        text: '文件上传中...',
        spinner: 'el-icon-loading',
        background: 'rgba(0, 0, 0, 0.7)'
      });
    },
    /**
     * 文件上传成功到pigx的统计文件管理后转发
     */
    handleUploadSuccess(response, file, fileList) {
      this.loading.close()
      this.$message.closeAll()
      if (response.data == 0) {
        this.$message.success(response.msg)
      } else {
        this.$message.error(response.msg)
      }

    },
    handleUploadError(response, file, fileList) {
      this.loading.close()
      this.$message.closeAll()
      this.$message.error('上传出错：' + response.data.message)
    },
    handleUploadSuccessTwo(response, file, fileList){
      this.$message.closeAll()
      if (response.code !== 0) {
        this.$message.error("上传出错：" + response.msg);
        this.loading.close()
        return;
      }
      this.bLoading = true;
      request({
        url:
          "/jiangjin/jiangjinryxxb/importRyxxbList/" +
          response.data.bucketName +
          "/" +
          response.data.fileName ,
        method: "get",
      })
        .then((res) => {
          if(res.data.msg!='OK'){
            this.loading.close()
             this.$message.closeAll();
            this.$message.warning(res.data.msg);

          }else{

             this.loading.close()
             this.bLoading = false;
             this.$message.closeAll();
             this.$message.success("导入成功!");
             this.getDataList(1)
          }


        })
        .catch((error) => {
          this.bLoading = false;
          this.$message.closeAll();
          this.loading.close()
          this.$message.error("导入模板中数据存在异常!");

        });
    },
    //系数详细配置
    btnAllocationXxPz() {
      if (this.multipleSelection.length === 0) {
        this.$notify.closeAll()
        this.$notify.error("请选择人员")
        return
      }
      var ryCodes = this.multipleSelection.map((item) => {
        return item.ryCode
      })
      this.allocationVisibleXxPz = true;
      this.$nextTick(() => {
        this.$refs.tallocationXxPz.init({deptId: this.deptId, deptName: this.deptName,ryCodes:ryCodes})
      })
    },
  }
}

</script>
<style lang="less">
.el-select {
  position: relative;

  .el-select__tags {
    position: inherit;
    transform: translateY(0);
    padding: 3px 0;
    min-height: 28px;
  }

  .el-select__tags ~ .el-input {
    height: 100%;
    position: absolute;
    top: 50%;
    left: 0;
    transform: translateY(-50%);

    .el-input__inner {
      min-height: 20px;
      height: 100% !important;
    }
  }

  .el-select__input.is-mini {
    min-height: 20px;
  }
}
</style>
